//
//  CheckGoodsInforTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/21.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "CheckGoodsInforTableViewCell.h"

@interface CheckGoodsInforTableViewCell (){
    GLGWLabel * storeNameLabel;
    GLGWLabel * goodsNameLabel;
    GLGWLabel * specLabel;
    GLGWLabel * piceLabel;
    GLGWLabel * goodsNumLabel;
    
}
@property(nonatomic,strong)MASConstraint *lable2TopConstraint;

@end

@implementation CheckGoodsInforTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        storeNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:kColor_Rule_Black inSuperView:self.contentView];
        [storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        //
        goodsNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self.contentView];
        [goodsNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self->storeNameLabel);
            self.lable2TopConstraint = make.top.equalTo(self->storeNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        specLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:self.contentView];
        [specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self->goodsNameLabel);
            make.top.equalTo(self->goodsNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //钱
        piceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:self.contentView];
        [piceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self->specLabel);
            make.top.equalTo(self->specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(5));
        }];
        //
        goodsNumLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:self.contentView];
        [goodsNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
    }
    return self;
}

-(void)setProductModel:(ShopCarModel_Data *)productModel{
    _productModel = productModel;
    if (_productModel.isSimilar) {
        storeNameLabel.attributedText = [GLGWLabel addImageName:@"icon_dianpu_jinru" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(17), kHeightProportion_In_iPhoneTriploid(15)) theTextString:[NSString stringWithFormat:@"  %@",koString(_productModel.shopName)] atImageIndex:0];
    }else{
        [self.lable2TopConstraint  uninstall];
        [goodsNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            self.lable2TopConstraint= make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
        }];
    }
    //
    goodsNameLabel.text = [NSString stringWithFormat:@"%@  %@  %@",koString(_productModel.productName),koString(_productModel.productMaterial),koString(_productModel.factoryName)];
    specLabel.text = _productModel.specifications;
    //
    piceLabel.attributedText = [GLGWLabel bllChangeStr:[NSString stringWithFormat:@"¥%.2f（%.2f吨）",_productModel.price,_productModel.singleWeight] changewithStr:[NSString stringWithFormat:@"（%.2f吨）",_productModel.singleWeight] changeColoer:[UIColor colorWithHexString:@"#EC5353"] withFont:SYSTEMFONT(12)];
    //
    goodsNumLabel.text = [NSString stringWithFormat:@"%d件",_productModel.num];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
